// pages/entering/entering.js
var app = getApp();
var com = require('../../common.js')
var lson = require('../../utils/list.js')
Page({
  data: {
    type: 1,
    jy_zd: false,
    yy_zd: false,
    id: '',
    string: {},
    name: ''
  },
  onLoad: function(options) {
    var _this = this
    console.log(options)
    if (options.string) {
      let list = JSON.parse(options.string)
      _this.setData({
        info: list,
        jy_zd: list.jy_zd,
        yy_zd: list.yy_zd,
        listinfo: lson.listYl
      })
    }
    _this.setData({
      listinfo: lson.listYl
    })
  },
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {},
  onShareAppMessage: function() {},
  affirm: function(e) {
    var _this = this
    let pages = getCurrentPages();
    let prevPage = pages[pages.length - 2];
    prevPage.setData({
      string: e.detail.value,
      jy_zd: _this.data.jy_zd,
      yy_zd: _this.data.yy_zd,
    })
    wx.navigateBack({
      delta: 1
    })
  },
  ontype(e) {
    var _this = this
    _this.setData({
      type: e.currentTarget.id,
    })
  },
  checkbox(e) {
    console.log(e)
    var _this = this,
      id = _this.data.type
    if (id == 1) {
      _this.setData({
        jy_zd: e.currentTarget.id == 1 ? true : false
      })
    } else {
      _this.setData({
        yy_zd: e.currentTarget.id == 1 ? true : false
      })
    }
  },
  onPickerMove(e) {
    var _this = this,
      list = _this.data.listinfo,
      string = _this.data.string,
      id = e.currentTarget.id,
      name = e.currentTarget.dataset.name
    if (id == 1) {
      string.jy_l_qj = list.qj[e.detail.value]
    }
    if (id == 2) {
      string.jy_r_qj = list.qj[e.detail.value]
    }
    if (id == 3) {
      string.jy_l_zj = list.zj[e.detail.value]
    }
    if (id == 4) {
      string.jy_r_zj = list.zj[e.detail.value]
    }
    if (id == 5) {
      string.jy_l_zx = list.zw[e.detail.value]
    }
    if (id == 6) {
      string.jy_r_zx = list.zw[e.detail.value]
    }
    if (id == 7) {
      string.jy_l_dyjzsl = list.dyjz[e.detail.value]
    }
    if (id == 8) {
      string.jy_r_dyjzsl = list.dyjz[e.detail.value]
    }
    if (id == 9) {
      string.jy_l_syjzsl = list.dyjz[e.detail.value]
    }
    if (id == 10) {
      string.jy_r_syjzsl = list.dyjz[e.detail.value]
    }
    if (id == 11) {
      string.jy_l_tj = list.tj[e.detail.value]
    }
    if (id == 12) {
      string.jy_r_tj = list.tj[e.detail.value]
    }
    if (id == 13) {
      string.jy_l_xjg = list.add[e.detail.value]
    }
    if (id == 14) {
      string.jy_r_xjg = list.add[e.detail.value]
    }
    // ---------------------------------------------
    if (id == 15) {
      string.yy_l_qj = list.qj[e.detail.value]
    }
    if (id == 16) {
      string.yy_r_qj = list.qj[e.detail.value]
    }
    if (id == 17) {
      string.yy_l_zj = list.zj[e.detail.value]
    }
    if (id == 18) {
      string.yy_r_zj = list.zj[e.detail.value]
    }
    if (id == 19) {
      string.yy_l_zx = list.zw[e.detail.value]
    }
    if (id == 20) {
      string.yy_r_zx = list.zw[e.detail.value]
    }
    if (id == 21) {
      string.yy_l_dyjzsl = list.dyjz[e.detail.value]
    }
    if (id == 22) {
      string.yy_r_dyjzsl = list.dyjz[e.detail.value]
    }
    if (id == 23) {
      string.yy_l_syjzsl = list.dyjz[e.detail.value]
    }
    if (id == 24) {
      string.yy_r_syjzsl = list.dyjz[e.detail.value]
    }
    if (id == 25) {
      string.yy_l_tj = list.tj[e.detail.value]
    }
    if (id == 26) {
      string.yy_r_tj = list.tj[e.detail.value]
    }
    if (id == 27) {
      string.yy_l_xjg = list.add[e.detail.value]
    }
    if (id == 28) {
      string.yy_r_xjg = list.add[e.detail.value]
    }
    _this.setData({
      string: string
    })

  }
})